package team.knowers.qzh.qzhgrame.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import team.knowers.qzh.qzhgrame.dao.entity.SubjectDO;
import team.knowers.qzh.qzhgrame.dao.mapper.SubjectMapper;
import team.knowers.qzh.qzhgrame.dto.resp.ShowSubjectRespDTO;
import team.knowers.qzh.qzhgrame.service.SubjectGrameService;

import java.util.ArrayList;
import java.util.List;

@Service
@AllArgsConstructor
public class SubjectGrameServiceImpl extends ServiceImpl<SubjectMapper, SubjectDO> implements SubjectGrameService {
    @Override
    public List<ShowSubjectRespDTO> showsubject() {
        LambdaQueryWrapper<SubjectDO> queryWrapper= Wrappers.lambdaQuery(SubjectDO.class)
                .eq(SubjectDO::getDelFlag,0)
                .orderByAsc(SubjectDO::getCreateTime);
        List<SubjectDO> subjectDOS=baseMapper.selectList(queryWrapper);
        List<ShowSubjectRespDTO> showSubjectRespDTOS=new ArrayList<>();
        for (SubjectDO one:subjectDOS)
        {
            showSubjectRespDTOS.add(BeanUtil.toBean(one,ShowSubjectRespDTO.class));
        }
        return showSubjectRespDTOS;
    }
}
